package de.milo.map.tile;

import org.newdawn.slick.Image;

/**
 * This class represents a tile of the map on the lowest layer.
 * @author Mizi
 *
 */
public class GroundTile implements MapTile
{
	private Image tileImage;
	private boolean isVisible;
	
	/**
	 * Creates a new groundtile with the given image.
	 * The visibility of this tile is set to false.
	 * @param tileImage the image of this groundtile
	 */
	public GroundTile(Image tileImage)
	{
		this(tileImage, false);
	}
	
	/**
	 * Creates a new groundtile with the given image
	 * and the given visibility
	 * @param tileImage the image of this groundtile
	 * @param isVisible sets the visibility of this groundtile
	 */
	public GroundTile(Image tileImage, boolean isVisible)
	{
		this.tileImage = tileImage;
		this.isVisible = isVisible;
	}
	
	@Override
	public String getInfo()
	{
		return "Groundtile";
	}
	
	@Override
	public boolean isVisible()
	{
		return isVisible;
	}
	
	@Override
	public void setVisible(boolean isVisible)
	{
		this.isVisible = isVisible;
		
	}
	
	@Override
	public void draw(float x, float y)
	{
		tileImage.draw(x, y);
	}
	
	@Override
	public void draw(float x, float y, int offsetX, int offsetY, int width, int height)
	{
		tileImage.getSubImage(offsetX, offsetY, width, height).draw(x, y);
	}
	
	@Override
	public void draw(float x, float y, float x2, float y2, int offsetX, int offsetY, int width, int height)
	{
		tileImage.getSubImage(offsetX, offsetY, width, height).draw(x, y, x2, y2, 0.f, 0.f, width, height);
	}
}
